package com.lincoln.framework.bean;

import com.lincoln.framework.interfaces.BaseProtocol;
import com.lincoln.framework.interfaces.MsgNoDeviceInfo;
import io.netty.channel.ChannelHandlerContext;
import lombok.Data;

/**
 * DeviceInfo默认实现类,使用String作为主键类型
 * @author lincoln
 */
@Data
public class AbstractMsgNoDeviceInfo extends MsgNoDeviceInfo<String> {
    private String deviceNo;
    private int deviceType;
    private int protocolType;
    /**
     * 是否已经被踢出
     */
    private boolean alive = true;

    public AbstractMsgNoDeviceInfo(String deviceNo, int deviceType, int protocolType, ChannelHandlerContext channelHandlerContext) {
        this.deviceNo = deviceNo;
        this.deviceType = deviceType;
        this.protocolType = protocolType;
        this.channelHandlerContext = channelHandlerContext;
    }

    @Override
    public boolean isLogin() {
        return !(null == deviceNo||"".equals(deviceNo));
    }

    @Override
    public String getPrimaryKey() {
        return deviceNo;
    }

    @Override
    public Integer getDeviceType() {
        return deviceType;
    }

    @Override
    public Integer getProtocolType() {
        return protocolType;
    }
}
